<style lang="less" scoped>

  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

  .f-w70 {
    width: 70%;
  }
</style>
<template>
  <section>
    <!--工具条-->
    <search-bar more-display>
      <el-row>
        <el-col :span="8">
          <el-form-item label="名称">
            <el-input  v-model="searchName" placeholder="名称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="节点类型">
            <el-select  v-model="searchNoteTypeValue" placeholder="请选择">
              <el-option
                v-for="item in searchNoteType"
                :label="item.cnDictValname"
                :key="item.id"
                :value="item.dictVal">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="状态">
            <el-select  v-model="myStatus" placeholder="请选择">
              <el-option
                v-for="item in isStart"
                :key="item.id"
                :label="item.cnDictValname"
                :value="item.dictVal">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="配载中心">
            <el-input  v-model="stowageCoreName" placeholder="配载中心"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </search-bar>

    <!-- 操作 -->
    <el-col :span="24" style="margin-bottom: 10px">
      <el-button type="primary" @click="handleAdd">新增</el-button>
      <el-button type="success" @click="batchStart">启用</el-button>
      <el-button type="warning" @click="batchStop">停用</el-button>
      <el-button type="danger" @click="batchDel">删除</el-button>
      <el-button type="primary" @click="myResert1" style="float: right">重置</el-button>
      <el-button type="primary" @click="mySearch" style="float: right">查询</el-button>
    </el-col>

    <!--列表-->
    <el-table :data="tableData" highlight-current-row border max-height="650"
              @selection-change="selsChange" v-loading="listLoading" style="width: 100%;">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column prop="isStartName" label="账户状态" >
      </el-table-column>
      <el-table-column prop="name" label="名称" width="150" >
      </el-table-column>
      <el-table-column prop="includeServiceName" label="服务范围包含" width="180" >
      </el-table-column>
      <el-table-column prop="notIncludeServiceName" label="服务范围不包含" width="250" >
      </el-table-column>
      <el-table-column prop="keyword" label="关键字" width="100" >
      </el-table-column>
      <el-table-column prop="stowageCoreName" label="配载中心" width="300" >
      </el-table-column>
      <el-table-column label="操作" width="250">
        <template slot-scope="scope">
          <el-button type="success" v-if="scope.row.isStart===111002002"
                     @click="handleStart(scope.$index, scope.row)">启用

          </el-button>
          <el-button type="warning" v-if="scope.row.isStart===111002001"
                     @click="handleStop(scope.$index, scope.row)">停用

          </el-button>
          <el-button  type="primary" @click="getEditBYId(scope.$index, scope.row)">编 辑</el-button>
          <el-button type="danger"  @click="handleDel(scope.$index, scope.row)">删 除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-pagination
        :current-page="currentPage"
        :page-size="pageSize"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total,sizes,prev, pager, next, jumper"
        :total="total" style="float: right">
      </el-pagination>
    </el-col>

    <!-- 弹窗 -->
    <el-dialog :title="dialogTitle" size="tiny" :visible.sync="mySpecialLineVisible" :close-on-click-modal="false">
      <el-form :model="mySpecialLine" :rules="rules" label-width="80px" ref="mySpecialLine">
        <el-form-item label="名称" prop="name">
          <el-input class="f-w70" v-model="mySpecialLine.name" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="范围类型" prop="type">
          <el-radio-group v-model="mySpecialLine.type">
            <el-radio class="radio" :label="109005001">直达</el-radio>
            <el-radio class="radio" :label="109005002">中转</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button  type="primary" @click="addIncludeArea()" style="float: right">新增</el-button>
        </el-form-item>
        <el-form-item label="范围">
          <el-table
            :data="tableDataGO"
            style="width: 400%">
            <el-table-column
              prop="province"
              label="包含省"
              width="150">
            </el-table-column>
            <el-table-column
              prop="city"
              label="包含市"
              width="150">
            </el-table-column>
            <el-table-column
              prop="county"
              label="包含区">
            </el-table-column>
            <el-table-column
              prop="notincludeProvince"
              label="不包含省"
              width="150">
            </el-table-column>
            <el-table-column
              prop="notincludeCity"
              label="不包含市"
              width="150">
            </el-table-column>
            <el-table-column
              width="180"
              prop="notincludeCounty"
              label="不包含区">
            </el-table-column>

            <el-table-column label="操作" width="150">
              <template slot-scope="scope">
                <el-button  type="primary"
                           @click="getEditAddressBYId(scope.$index, scope.row)">编辑
                </el-button>
                <el-button type="danger"
                           @click.native.prevent="handleAddressDel(scope.$index, tableDataGO)"
                >删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>
        <el-form-item label="关键字" prop="keyword">
          <el-input class="f-w70" v-model="mySpecialLine.keyword" auto-complete="off"
                    placeholder="请输入关键字"></el-input>
        </el-form-item>
        <el-form-item label="排序" prop="sorts">
          <el-input class="f-w70" v-model="mySpecialLine.sorts" auto-complete="off"
                    placeholder="请输入排序号"></el-input>
        </el-form-item>
        <el-form-item label="配载节点">
          <el-select class="f-w70" clearable
                     v-model="mySpecialLine.stowageNodeId"
                     remote
                     :remote-method="searchStowageCore"
                     filterable
                     value-key="id"
                     placeholder="请选择配载节点">
            <el-option
              v-for="sn in stowageNodes"
              :label="sn.name"
              :key="sn.id"
              :value="sn.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="配载中心" prop="stowageCoreCenter2">
          <el-cascader class="f-w70"
                       placeholder="请选择配载中心"
                       :options="$store.state.initOrganizations"
                       :props="{label: 'name',value: 'id'}"
                       change-on-select
                       v-model="mySpecialLine.stowageCoreCenter2"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
                    <textarea class="f-w70" v-model="mySpecialLine.remark" rows="5" cols="20" auto-complete="off"
                              placeholder="请输入备注信息"></textarea>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelAddress">取消</el-button>
        <el-button type="primary" @click.native="handleSubmit" :loading="submitLoading">提交</el-button>
      </div>
    </el-dialog>
    <!-- 地址弹窗 -->
    <el-dialog :title="includeTitle"  :visible.sync="myIncludeAreaVisible" :close-on-click-modal="false">
      <el-form :model="myIncludeArea" label-width="90px" ref="myIncludeArea">
        <el-form-item label="包含省">
          <el-select clearable  v-model="myIncludeArea.province" @change="myProvince"
                     @clear="myProvinceClear"
                     value-key="id"
                     placeholder="请选择省">
            <el-option
              v-for="item in includeProvinceValue"
              :label="item.name"
              :key="item.id"
              :value="item">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="包含市">
          <el-select clearable  v-model="myIncludeArea.provinceAndCity"
                     value-key="id"
                     @clear="myIncludeProvinceClear" @change="myIncludeProvince" placeholder="请选择省">
            <el-option
              v-for="item in provinceAndCityIdValue"
              :label="item.name"
              :key="item.id"
              :value="item">
            </el-option>
          </el-select>

          <el-select clearable v-model="myIncludeArea.city"
                     @clear="myProvinceAndCityClear"
                     value-key="id"
                     @change="myProvinceAndCity" placeholder="请选择市">
            <el-option
              v-for="item in includeCityValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="包含区">
          <el-select clearable  v-model="myIncludeArea.provinceAndCityAndCounry"
                     @change="includeProvinceAndCityAndCounry"
                     @clear="includeProvinceAndCityAndCounryClear"
                     value-key="id"
                     placeholder="请选择省">
            <el-option
              v-for="item in provinceAndCityAndCounryValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>

          <el-select clearable v-model="myIncludeArea.cityAndCounry"
                     @clear="includeCityClear"
                     value-key="id"
                     @change="includeCity" placeholder="请选择市">
            <el-option
              v-for="item in includeCityAndCounryValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>
          <el-select clearable v-model="myIncludeArea.county" @change="myIncludeCityAndCounty"
                     @clear="myIncludeCityAndCountyClear"
                     value-key="id"
                     placeholder="请选择区/县">
            <el-option
              v-for="item in includeCountyValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="不包含省">
          <el-select clearable  @change="myNotIncludeProvince"
                     @clear="myNotIncludeProvinceClear"
                     value-key="id"
                     v-model="myIncludeArea.notincludeProvince"
                     placeholder="请选择省">
            <el-option
              v-for="item in notIncludeProvinceValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="不包含市">
          <el-select clearable  v-model="myIncludeArea.notincludeProvinceAndCity"
                     @change="notIncludeProvinceAndCity"
                     value-key="id"
                     @clear="notIncludeProvinceAndCityClear"
                     placeholder="请选择省">
            <el-option
              v-for="item in notIncludeProvinceAndCityIdValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>
          <el-select clearable v-model="myIncludeArea.notincludeCity"
                     @change="myNotIncludeCity"
                     @clear="myNotIncludeCityClear"
                     value-key="id"
                     placeholder="请选择市">
            <el-option
              v-for="item in notIncludeCityValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="不包含区">
          <el-select clearable  v-model="myIncludeArea.notincludeProvinceAndCityAndCounry"
                     @change="notIncludeProvinceAndCityAndCounry"
                     value-key="id"
                     @clear="notIncludeProvinceAndCityAndCounryClear"
                     placeholder="请选择省">
            <el-option
              v-for="item in notIncludeprovinceAndCityAndCounryValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>

          <el-select clearable v-model="myIncludeArea.notincludeCityAndCounry"
                     @change="notIncludeCityAndCounry"
                     value-key="id"
                     @clear="notIncludeCityAndCounryClear"
                     placeholder="请选择市">
            <el-option
              v-for="item in notincludeCityAndCounryValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>
          <el-select clearable v-model="myIncludeArea.notincludeCounty  "
                     @change="myIncludeCounty"
                     @clear="myIncludeCountyClear"
                     value-key="id"
                     placeholder="请选择区/县">
            <el-option
              v-for="item in notIncludeCountyValue"
              :label="item.name"
              :value="item"
              :key="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="myIncludeAreaVisible = false">取消</el-button>
        <el-button type="primary" @click="myAreaSave">提交</el-button>
      </div>
    </el-dialog>
  </section>
</template>

<script>
import {
  searchDictEntitys,
  searchSpecialLines,
  batchStart,
  batchDel,
  saveSpecialLine,
  getAddresses,
  findByUserIdAndSpecialLineId,
  getSpecialLine,
  getSpecialLineAddress
} from '../../api/system/SpecialLine.js';
import { searchStowageCore } from '../../api/system/stowageCore.js';
import { isEmpty, getSelectObect } from '../../lib/util.js';

export default {
  data () {
    return {
      currentIndex: '',
      currentRowId: '', // 当前的ROWID
      currentRow: '', // 当前的ROWID
      myStatus: '',
      tableDataGO: [],
      includeTitle: '新增地址', // 新增地址标题
      condition: {
        name: '',
        number: ''
      },
      isStart: [], // 大画面的类型类型
      isStartValue: '', // 显示值
      organization1: '',
      stowageCore1: '',
      searchNoteType: [], // 搜索栏的节点类型
      stowageCoreName: null,
      searchNoteTypeValue: '', // 搜索栏节点显示值
      searchStowageCoreCenter2: [], // 搜索栏配载中心
      searchStowageCoreprops: { // 搜索栏配载中心的props
        label: 'name',
        value: 'id',
        children: 'children'
      },

      searchName: '', // 搜索栏的名称
      stowageValue: [], // 配载中心
      includeProvinceValue: [], // 包含省
      provinceAndCityIdValue: [], // 包含省-有市
      provinceAndCityAndCounryValue: [], // 包含省-有市 -有区
      includeCityValue: [], // 包含城市
      includeCityAndCounryValue: [], // 包含城-区
      includeCountyValue: [], // 包含区/县
      notIncludeProvinceValue: [], // 不包含省
      notIncludeProvinceAndCityIdValue: [], // 不包含省 有--市
      notIncludeprovinceAndCityAndCounryValue: [], // 不包含省 有--市 --区
      notIncludeCityValue: [], // 不包含城市
      notincludeCityAndCounryValue: [], // 不包含城市有区
      notIncludeCountyValue: [], // 不包含区/县
      controlCenter2: [],
      stowageCoreCenter2: [],
      searchBarStowageCore: [],
      props: {
        label: 'name',
        value: 'id',
        children: 'children'
      },
      props1: {
        label: 'name',
        value: 'id',
        children: 'children'
      },
      searchProps: {
        label: 'name',
        value: 'id',
        children: 'children'
      },
      dialogTitle: '新增',
      sels: [],
      tableData: [],
      total: 0,
      currentPage: 1,
      pageSize: 10,
      sortProp: null,
      sortOrder: 'ascending',
      listLoading: false,
      mySpecialLineVisible: false,
      myIncludeAreaVisible: false,
      submitLoading: false,
      stowageNodes: [],
      // 表单数据
      mySpecialLine: {
        'id': null,
        'name': null,
        'type': null,
        'keyword': null,
        'sorts': null,
        'stowageCoreId': null,
        'addressId': '',
        'tableDataGO': [],
        'stowageCoreCenter2': [],
        stowageNodeId: '',
        stowageNodeName: '',
        'remark': null,
        // 表单数据
        myIncludeArea: {
          'id': null,
          'notincludeProvince': null,
          'notincludeProvinceId': null,

          'notincludeProvinceAndCity': null,
          'notincludeProvinceAndCityId': null,

          'notincludeProvinceAndCityAndCounry': null,
          'notincludeProvinceAndCityAndCounryId': null,

          'notincludeCity': null,
          'notincludeCityId': null,

          'notincludeCityAndCounry': null,
          'notincludeCityAndCounryId': null,

          'notincludeCounty': null,
          'notincludeCountyId': null,

          'province': null,
          'provinceId': null,

          'provinceAndCity': null,
          'provinceAndCityId': null,

          'provinceAndCityAndCounry': null,
          'provinceAndCityAndCounryId': null,

          'city': null,
          'cityId': null,

          'cityAndCounry': null,
          'cityAndCounryId': null,

          'county': null,
          'countyId': null,

          'specialLineId': null
        }
      },

      // 表单数据
      myIncludeArea: {
        'id': null,
        'notincludeProvince': null,
        'notincludeProvinceId': null,

        'notincludeProvinceAndCity': null,
        'notincludeProvinceAndCityId': null,

        'notincludeProvinceAndCityAndCounry': null,
        'notincludeProvinceAndCityAndCounryId': null,

        'notincludeCity': null,
        'notincludeCityId': null,

        'notincludeCityAndCounry': null,
        'notincludeCityAndCounryId': null,

        'notincludeCounty': null,
        'notincludeCountyId': null,

        'province': null,
        'provinceId': null,

        'provinceAndCity': null,
        'provinceAndCityId': null,

        'provinceAndCityAndCounry': null,
        'provinceAndCityAndCounryId': null,

        'city': null,
        'cityId': null,

        'cityAndCounry': null,
        'cityAndCounryId': null,

        'county': null,
        'countyId': null,

        'specialLineId': null

      },

      // 验证规则
      rules: {
        name: [
          {required: true, message: '请输入姓名', trigger: 'blur'},
          {min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur'}
        ],
        stowageCoreCenter2: [
          {type: 'array', required: true, message: '请选择配载中心', trigger: 'blur'}
        ],
        type: [
          {type: 'number', required: true, message: '请选择范围类型', trigger: 'blur'}
        ]
      }
    };
  },
  methods: {
    myProvinceClear () {
      this.mySpecialLine.myIncludeArea.province = null;
      this.mySpecialLine.myIncludeArea.provinceId = null;
    },
    // 包含省有市-  省-选择时触 发 清空
    myIncludeProvinceClear () {
      this.mySpecialLine.myIncludeArea.provinceAndCity = null;
      this.mySpecialLine.myIncludeArea.provinceAndCityId = null;
    },
    //  包含省市 里的市 清空
    myProvinceAndCityClear () {
      this.mySpecialLine.myIncludeArea.city = null;
      this.mySpecialLine.myIncludeArea.cityId = null;
    },

    // 清空 --包含省有市有区-  省选择时触 发
    includeProvinceAndCityAndCounryClear () {
      this.mySpecialLine.myIncludeArea.provinceAndCityAndCounry = null;
      this.mySpecialLine.myIncludeArea.provinceAndCityAndCounryId = null;
    },

    //  清空 包含省-有市有区   市 选择时触 发
    includeCityClear () {
      this.mySpecialLine.myIncludeArea.cityAndCounry = null;
      this.mySpecialLine.myIncludeArea.cityAndCounryId = null;
    },
    // 清空  包含省-有市有区   区 选择时触 发
    myIncludeCityAndCountyClear () {
      this.mySpecialLine.myIncludeArea.county = null;
      this.mySpecialLine.myIncludeArea.countyId = null;
    },

    // 清空 --，不包含省
    myNotIncludeProvinceClear () {
      this.mySpecialLine.myIncludeArea.notincludeProvince = null;
      this.mySpecialLine.myIncludeArea.notincludeProvinceId = null;
    },

    // 清空 --不包含省有市-  省-选择时触 发
    notIncludeProvinceAndCityClear () {
      this.mySpecialLine.myIncludeArea.notincludeProvinceAndCity = null;
      this.mySpecialLine.myIncludeArea.notincludeProvinceAndCityId = null;
    },

    // 清空 --不包含省有市 ---市 选择
    myNotIncludeCityClear () {
      this.mySpecialLine.myIncludeArea.notincludeCity = null;
      this.mySpecialLine.myIncludeArea.notincludeCityId = null;
    },
    // 清空  不包含省份有市有区   省选择时触 发
    notIncludeProvinceAndCityAndCounryClear () {
      this.mySpecialLine.myIncludeArea.notincludeProvinceAndCityAndCounry = null;
      this.mySpecialLine.myIncludeArea.notincludeProvinceAndCityAndCounryId = null;
    },
    // 清空--不包含城市选择时触 发
    notIncludeCityAndCounryClear () {
      this.mySpecialLine.myIncludeArea.notincludeCityAndCounry = null;
      this.mySpecialLine.myIncludeArea.notincludeCityAndCounryId = null;
    },

    myIncludeCountyClear () {
      this.mySpecialLine.myIncludeArea.notincludeCounty = null;
      this.mySpecialLine.myIncludeArea.notincludeCountyId = null;
    },

    // 赋值--包含省
    myProvince (event) {
      this.mySpecialLine.myIncludeArea.province = event.name;
      this.mySpecialLine.myIncludeArea.provinceId = event.id;
    },

    // 包含省有市-  省-选择时触 发
    myIncludeProvince (event) {
      this.mySpecialLine.myIncludeArea.provinceAndCity = event.name;
      this.mySpecialLine.myIncludeArea.provinceAndCityId = event.id;
      getAddresses(event.id).then((res) => {
        if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
          this.includeCityValue = res.data.detailModelList;
        }
      });
    },
    // 赋值 --包含省市 里的市
    myProvinceAndCity (event) {
      this.mySpecialLine.myIncludeArea.city = event.name;
      this.mySpecialLine.myIncludeArea.cityId = event.id;
    },
    // 赋值 --包含省有市有区-  省选择时触 发
    includeProvinceAndCityAndCounry (event) {
      this.mySpecialLine.myIncludeArea.provinceAndCityAndCounry = event.name;
      this.mySpecialLine.myIncludeArea.provinceAndCityAndCounryId = event.id;
      getAddresses(event.id).then((res) => {
        if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
          this.includeCityAndCounryValue = res.data.detailModelList;
        }
      });
    },
    // 赋值  包含省-有市有区   市 选择时触 发
    includeCity (event) {
      this.mySpecialLine.myIncludeArea.cityAndCounry = event.name;
      this.mySpecialLine.myIncludeArea.cityAndCounryId = event.id;
      getAddresses(event.id).then((res) => {
        if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
          this.includeCountyValue = res.data.detailModelList;
        }
      });
    },
    // 赋值  包含省-有市有区   区 选择时触 发
    myIncludeCityAndCounty (event) {
      this.mySpecialLine.myIncludeArea.county = event.name;
      this.mySpecialLine.myIncludeArea.countyId = event.id;
    },

    // 赋值 --，不包含省
    myNotIncludeProvince (event) {
      this.mySpecialLine.myIncludeArea.notincludeProvince = event.name;
      this.mySpecialLine.myIncludeArea.notincludeProvinceId = event.id;
    },

    // 赋值--不包含省有市-  省-选择时触 发
    notIncludeProvinceAndCity (event) {
      this.mySpecialLine.myIncludeArea.notincludeProvinceAndCity = event.name;
      this.mySpecialLine.myIncludeArea.notincludeProvinceAndCityId = event.id;
      getAddresses(event.id).then((res) => {
        if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
          this.notIncludeCityValue = res.data.detailModelList;
        }
      });
    },
    // 赋值 --不包含省有市 ---市 选择
    myNotIncludeCity (event) {
      this.mySpecialLine.myIncludeArea.notincludeCity = event.name;
      this.mySpecialLine.myIncludeArea.notincludeCityId = event.id;
    },
    // 赋值  不包含省份有市有区   省选择时触 发
    notIncludeProvinceAndCityAndCounry (event) {
      this.mySpecialLine.myIncludeArea.notincludeProvinceAndCityAndCounry = event.name;
      this.mySpecialLine.myIncludeArea.notincludeProvinceAndCityAndCounryId = event.id;
      getAddresses(event.id).then((res) => {
        if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
          this.notincludeCityAndCounryValue = res.data.detailModelList;
        }
      });
    },
    // 赋值--不包含城市选择时触 发
    notIncludeCityAndCounry (event) {
      this.mySpecialLine.myIncludeArea.notincludeCityAndCounry = event.name;
      this.mySpecialLine.myIncludeArea.notincludeCityAndCounryId = event.id;
      getAddresses(event.id).then((res) => {
        if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
          this.notIncludeCountyValue = res.data.detailModelList;
        }
      });
    },

    myIncludeCounty (event) {
      this.mySpecialLine.myIncludeArea.notincludeCounty = event.name;
      this.mySpecialLine.myIncludeArea.notincludeCountyId = event.id;
    },

    // 新增时取消短驳时的方法
    cancelAddress () {
      this.mySpecialLineVisible = false;
    },
    // 地址重置
    myAddressRest () {
      this.myIncludeArea.provinceId = '';
      this.myIncludeArea.provinceAndCityId = '';
      this.myIncludeArea.cityId = '';
      this.myIncludeArea.provinceAndCityAndCounryId = '';
      this.myIncludeArea.cityAndCounryId = '';
      this.myIncludeArea.countyId = '';

      this.myIncludeArea.notincludeProvinceId = '';
      this.myIncludeArea.notincludeProvinceAndCityId = '';
      this.myIncludeArea.notincludeCityId = '';
      this.myIncludeArea.notincludeProvinceAndCityAndCounryId = '';
      this.myIncludeArea.notincludeCityAndCounryId = '';
      this.myIncludeArea.notincludeCountyId = '';
    },

    // 删除单条专线地址数据操作
    handleAddressDel (index, row) {
      row.splice(index, 1);
    },

    // 打开专线地址编辑界面
    getEditAddressBYId (index, row) {
      this.myAddressRest();
      this.addGetAddress();
      this.currentRowId = row.id;
      this.currentRow = row;
      this.currentIndex = index;
      this.dialogTitle = '地址修改';

      this.mySpecialLine.myIncludeArea = Object.assign({
        'id': null,
        'notincludeProvince': null,
        'notincludeProvinceId': null,

        'notincludeProvinceAndCity': null,
        'notincludeProvinceAndCityId': null,

        'notincludeProvinceAndCityAndCounry': null,
        'notincludeProvinceAndCityAndCounryId': null,

        'notincludeCity': null,
        'notincludeCityId': null,

        'notincludeCityAndCounry': null,
        'notincludeCityAndCounryId': null,

        'notincludeCounty': null,
        'notincludeCountyId': null,

        'province': null,
        'provinceId': null,

        'provinceAndCity': null,
        'provinceAndCityId': null,

        'provinceAndCityAndCounry': null,
        'provinceAndCityAndCounryId': null,

        'city': null,
        'cityId': null,

        'cityAndCounry': null,
        'cityAndCounryId': null,

        'county': null,
        'countyId': null,

        'specialLineId': null
      }, row);
      this.myIncludeAreaVisible = true;
    },

    addGetAddress () {
      // 初始化载入省份
      getAddresses('156').then((res) => {
        if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
          this.includeProvinceValue = res.data.detailModelList;
          this.provinceAndCityIdValue = res.data.detailModelList;
          this.provinceAndCityAndCounryValue = res.data.detailModelList;

          this.notIncludeProvinceValue = res.data.detailModelList;
          this.notIncludeProvinceAndCityIdValue = res.data.detailModelList;
          this.notIncludeprovinceAndCityAndCounryValue = res.data.detailModelList;
        }
      });
    },

    // 打开地址界面
    addIncludeArea () {
      this.myAddressRest();
      this.addGetAddress();
      this.currentRowId = 123456789;
      this.includeTitle = '新增地址';
      this.mySpecialLine.myIncludeArea = {};
      this.myIncludeAreaVisible = true;
    },

    // 搜索
    mySearch () {
      // 名称
      let filters = '';
      if (this.searchName !== '' && this.searchName !== null) {
        filters += 'name?' + this.searchName + ' g0;';
      }
      // 范围类型
      if (this.searchNoteTypeValue !== '' && this.searchNoteTypeValue !== null) {
        filters += 'type=' + this.searchNoteTypeValue + ' g1;';
      }

      // 状态
      if (this.myStatus !== '' && this.myStatus !== null) {
        filters += 'isStart=' + this.myStatus + ' g9;';
      }
      if (this.stowageCoreName !== '' && this.stowageCoreName !== null) {
        filters += 'stowageCoreName?' + this.stowageCoreName + ' g10;';
      }
      searchSpecialLines({
        page: this.currentPage,
        size: this.pageSize,
        filters: filters,
        sorts: (this.sortProp === null ? '' : (this.sortOrder === 'ascending' ? '-' : '+') + this.sortProp)
      }).then((res) => {
        if (res.data.successFlg === true) {
          this.tableData = res.data.detailModelList;
          this.currentPage = res.data.currPage;
          this.total = res.data.totalCount;
          this.pageSize = res.data.pageSize;
          this.listLoading = false;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    // 获取专线地址
    getSpecialLineAddresss (id) {
      getSpecialLineAddress(id).then((res) => {
        if (res.data.successFlg === true) {
          this.tableDataGO = res.data.detailModelList;
          this.currentPage = res.data.currPage;
          this.total = res.data.totalCount;
          this.pageSize = res.data.pageSize;
          this.listLoading = false;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    // 保存专线地址
    myAreaSave () {
      if (isEmpty(this.mySpecialLine.myIncludeArea.province) && isEmpty(this.mySpecialLine.myIncludeArea.city) && isEmpty(this.mySpecialLine.myIncludeArea.county) && isEmpty(this.mySpecialLine.myIncludeArea.notincludeProvince) && isEmpty(this.mySpecialLine.myIncludeArea.notincludeCity) && isEmpty(this.mySpecialLine.myIncludeArea.notincludeCounty)) {
        this.$message.error('请至少选择一项地址！');
        return;
      }
      let routeFreightNew = '';
      if (this.tableDataGO.length > 0) {
        for (let x = 0; x < this.tableDataGO.length; x++) {
          if (this.currentRowId === this.tableDataGO[x].id) {
            this.tableDataGO.splice(this.currentIndex, 1);
            routeFreightNew = Object.assign({
              'id': null,
              'notincludeProvince': null,
              'notincludeProvinceId': null,

              'notincludeProvinceAndCity': null,
              'notincludeProvinceAndCityId': null,

              'notincludeProvinceAndCityAndCounry': null,
              'notincludeProvinceAndCityAndCounryId': null,

              'notincludeCity': null,
              'notincludeCityId': null,

              'notincludeCityAndCounry': null,
              'notincludeCityAndCounryId': null,

              'notincludeCounty': null,
              'notincludeCountyId': null,

              'province': null,
              'provinceId': null,

              'provinceAndCity': null,
              'provinceAndCityId': null,

              'provinceAndCityAndCounry': null,
              'provinceAndCityAndCounryId': null,

              'city': null,
              'cityId': null,

              'cityAndCounry': null,
              'cityAndCounryId': null,

              'county': null,
              'countyId': null,

              'specialLineId': null
            }, this.mySpecialLine.myIncludeArea);
          } else {
            routeFreightNew = Object.assign({
              'id': null,
              'notincludeProvince': null,
              'notincludeProvinceId': null,

              'notincludeProvinceAndCity': null,
              'notincludeProvinceAndCityId': null,

              'notincludeProvinceAndCityAndCounry': null,
              'notincludeProvinceAndCityAndCounryId': null,

              'notincludeCity': null,
              'notincludeCityId': null,

              'notincludeCityAndCounry': null,
              'notincludeCityAndCounryId': null,

              'notincludeCounty': null,
              'notincludeCountyId': null,

              'province': null,
              'provinceId': null,

              'provinceAndCity': null,
              'provinceAndCityId': null,

              'provinceAndCityAndCounry': null,
              'provinceAndCityAndCounryId': null,

              'city': null,
              'cityId': null,

              'cityAndCounry': null,
              'cityAndCounryId': null,

              'county': null,
              'countyId': null,

              'specialLineId': null
            }, this.mySpecialLine.myIncludeArea);
          }
        }
      } else {
        routeFreightNew = Object.assign({
          'id': null,
          'notincludeProvince': null,
          'notincludeProvinceId': null,

          'notincludeProvinceAndCity': null,
          'notincludeProvinceAndCityId': null,

          'notincludeProvinceAndCityAndCounry': null,
          'notincludeProvinceAndCityAndCounryId': null,

          'notincludeCity': null,
          'notincludeCityId': null,

          'notincludeCityAndCounry': null,
          'notincludeCityAndCounryId': null,

          'notincludeCounty': null,
          'notincludeCountyId': null,

          'province': null,
          'provinceId': null,

          'provinceAndCity': null,
          'provinceAndCityId': null,

          'provinceAndCityAndCounry': null,
          'provinceAndCityAndCounryId': null,

          'city': null,
          'cityId': null,

          'cityAndCounry': null,
          'cityAndCounryId': null,

          'county': null,
          'countyId': null,

          'specialLineId': null
        }, this.mySpecialLine.myIncludeArea);
      }

      this.tableDataGO.push(routeFreightNew);
      this.myIncludeAreaVisible = false;
    },

    // 搜索栏重置
    myResert1 () {
      this.searchName = '';
      this.searchNoteTypeValue = '';
      this.searchNoteTypeValue = '';
      this.myStatus = '';
      this.searchStowageCoreCenter2 = [];
    },

    // 打开编辑界面
    getEditBYId (index, row) {
      getSpecialLine([row.id]).then((res) => {
        if (res.data.obj.isStart === 111002001) {
          this.$message.warning('已启用，无法编辑！');
        } else {
          this.searchStowageCore(row.stowageNodeName);
          this.mySpecialLine = Object.assign({}, row);
          this.mySpecialLine.myIncludeArea = {};
          this.getSpecialLineAddresss(row.id);
          this.mySpecialLine.stowageCoreCenter2 = this.mySpecialLine.stowageCoreId.split(',');
          this.dialogTitle = '修改';
          this.mySpecialLineVisible = true;
        }
      });
    },

    // 根据userid and markcargoid 查找短驳地址列表
    findByUserIdAndSpecialLineId (id) {
      findByUserIdAndSpecialLineId({
        userId: '',
        specialLineId: id
      }).then((res) => {
        if (res.data.successFlg === true) {
          this.tableDataGO = res.data.detailModelList;
          this.currentPage = res.data.currPage;
          this.total = res.data.totalCount;
          this.pageSize = res.data.pageSize;
          this.listLoading = false;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },

    // 删除单条数据操作
    handleDel (index, row) {
      getSpecialLine([row.id]).then((res) => {
        if (res.data.obj.isStart === 111002001) {
          this.$message.warning('已启用，无法删除！');
        } else {
          this.$confirm('确认删除该用户吗?', '提示', {
            type: 'warning'
          }).then(() => {
            this.listLoading = true;
            batchDel([row.id]).then((res) => {
              this.listLoading = false;
              this.$message({
                message: '删除成功！',
                type: 'success'
              });
              this.currentPage = 1;
              this.mySearch();
            });
          }).catch(() => {
          });
        }
      });
    },

    // 批量删除
    batchDel () {
      let id = this.sels.map(item => item.id);
      if (id === '' || id == null) {
        this.$message.error('请选择数据！');
        return;
      }

      getSpecialLine([id]).then((res) => {
        if (res.data.obj.isStart === 111002001) {
          this.$message.warning('已启用，无法删除！');
        } else {
          this.$confirm('确认删除该用户吗?', '提示', {
            type: 'warning'
          }).then(() => {
            this.listLoading = true;
            batchDel(id).then((res) => {
              this.listLoading = false;
              this.$message({
                message: '删除成功！',
                type: 'success'
              });
              this.mySearch();
            });
          }).catch(() => {
          });
        }
      });
    },

    // 单 条启用
    handleStart (index, row) {
      this.$confirm('确认启用该服务吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        let isStart = 111002001;
        batchStart([row.id], isStart).then((res) => {
          this.listLoading = false;
          this.$message({
            message: '启用成功！',
            type: 'success'
          });
          this.mySearch();
        });
      }).catch(() => {
      });
    },

    // 批量启用
    batchStart () {
      let id = this.sels.map(item => item.id);
      if (id === '' || id == null) {
        this.$message.error('请选择数据！');
        return;
      }
      this.$confirm('确认启用该服务吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        let isStart = 111002001;
        batchStart(id, isStart).then((res) => {
          this.listLoading = false;
          this.$message({
            message: '启用成功！',
            type: 'success'
          });
          this.mySearch();
        });
      }).catch(() => {
      });
    },

    // 单 条停用
    handleStop (index, row) {
      this.$confirm('确认停用该用户吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        let isStart = 111002002;
        batchStart([row.id], isStart).then((res) => {
          this.listLoading = false;
          this.$message({
            message: '停用成功！',
            type: 'success'
          });
          this.mySearch();
        });
      }).catch(() => {
      });
    },

    // 批量停用
    batchStop () {
      let id = this.sels.map(item => item.id);
      if (id === '' || id == null) {
        this.$message.error('请选择数据！');
        return;
      }
      this.$confirm('确认停用该用户吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        let isStart = 111002002;
        batchStart(id, isStart).then((res) => {
          this.listLoading = false;
          this.$message({
            message: '停用成功！',
            type: 'success'
          });
          this.mySearch();
        });
      }).catch(() => {
      });
    },

    // 新增修改数据提交
    handleSubmit () {
      this.$refs['mySpecialLine'].validate((valid) => {
        if (valid) {
          this.mySpecialLine.specialLineAddressList = this.tableDataGO;
          this.mySpecialLine.stowageCoreId = this.mySpecialLine.stowageCoreCenter2.join(',');
          this.mySpecialLine.stowageNodeName = isEmpty(this.mySpecialLine.stowageNodeId) ? null : getSelectObect(this.mySpecialLine.stowageNodeId, 'id', this.stowageNodes).name;
          this.submitLoading = true;
          saveSpecialLine(this.mySpecialLine).then((res) => {
            this.submitLoading = false;
            if (res.data.successFlg === true) {
              this.mySpecialLineVisible = false;
              this.mySearch();
              this.$message.success('保存/修改成功！');
            } else {
              this.$message.error(res.data.errorMsg);
            }
          }).catch(function (error) {
            console.log(error);
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 重置表单
    resetForm () {
      if (this.$refs.mySpecialLine) {
        this.$refs.mySpecialLine.resetFields();
      }
      // 当先点击修改，再点击新增，会出现值没有清空,修复处理
      for (let p in this.mySpecialLine) {
        if (this.mySpecialLine[p] instanceof Array) {
          this.mySpecialLine[p] = [];
        } else {
          this.mySpecialLine[p] = null;
        }
      }
    },
    // 弹出添加窗体
    handleAdd () {
      this.tableDataGO = [];
      this.stowageCoreCenter2 = [];
      this.dialogTitle = '新增';
      this.searchStowageCore();
      this.resetForm();
      this.mySpecialLineVisible = true;
    },

    // 多选操作
    selsChange (sels) {
      this.sels = sels;
    },
    // 排序操作
    sortChange (o) {
      this.sortProp = o.prop;
      this.sortOrder = o.order;
      this.mySearch();
    },
    // 每页几条操作
    handleSizeChange (val) {
      this.pageSize = val;
      this.mySearch();
    },
    // 第几页操作
    handleCurrentChange (val) {
      this.currentPage = val;
      this.mySearch();
    },
    // 重置查询条件
    resetCondition () {
      for (let p in this.condition) {
        this.condition[p] = null;
      }
    },
    // 获取表格数据
    getTableData () {
      this.listLoading = true;
      searchSpecialLines({
        page: this.currentPage,
        size: this.pageSize,
        filters: '',
        sorts: (this.sortProp === null ? '' : (this.sortOrder === 'ascending' ? '-' : '+') + this.sortProp)
      }).then((res) => {
        if (res.data.successFlg === true) {
          this.tableData = res.data.detailModelList;
          this.currentPage = res.data.currPage;
          this.total = res.data.totalCount;
          this.pageSize = res.data.pageSize;
          this.listLoading = false;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    searchStowageCore (val) {
      searchStowageCore({
        filters: isEmpty(val) ? '' : 'LIKE_name=' + val,
        size: 15,
        page: 1,
        sorts: '-createDate'
      }).then(res => {
        if (res.data.successFlg) {
          this.stowageNodes = res.data.detailModelList;
        } else {
          this.stowageNodes = [];
          this.$message.error(res.data.errorMsg);
        }
      });
    }
  },
  // 初始化数据
  mounted () {
    // 初始化载入开启类型
    searchDictEntitys('111002').then((res) => {
      if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
        this.isStart = res.data.detailModelList;
      }
    });

    // 初始化载入提/送货类型
    searchDictEntitys('109005').then((res) => {
      if (res.data.detailModelList !== '' && res.data.detailModelList !== null) {
        this.searchNoteType = res.data.detailModelList;
      }
    });
    // 初始化载入表格
    this.getTableData();
    this.$store.commit('initOrganizations');
  }
};
</script>

<style lang="less" scoped>

</style>
